package cn.messageplus.core.test;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.nextLine();
        String[] strings = s1.split(",");

        String minStr = strings[0];
        for (String s : strings) {
            if (s.length() < minStr.length()) {
                minStr = s;
            }
        }

        String result = "-";
        for (int i = 0; i < minStr.length(); ++i) {
            for (int j = i + 1; j <= minStr.length(); ++j) {
                String substring = minStr.substring(i, j);
                boolean bo = true;
                for (String s : strings) {
                    if (!s.contains(substring)) {
                        bo = false;
                        break;
                    }
                }
                if (bo&&substring.length()>result.length()) {
                    result = substring;
                }
            }
        }

        System.out.println(result);
    }
}
